import request from "@/utils/request";

import type { ITrademarkList, IBrand } from "./model";

enum API {
  TRADEMARKLIST = "/admin/product/baseTrademark/", // 分页列表
  ADDTRADEMARK = "/admin/product/baseTrademark/save", // 新增品牌
  UPDATETRADEMARK = "/admin/product/baseTrademark/update", // 修改品牌
  DELETETRADEMARK = "/admin/product/baseTrademark/remove/" // 删除品牌
}

// 获取品牌数据
export const reqTrademarkList = (page: number, limit: number) =>
  request.get<any, ITrademarkList>(API.TRADEMARKLIST + `${page}/${limit}`);

// 添加或更新品牌
export const reqAddOrUpdateTrademark = (data: IBrand) => {
  if (data.id) {
    return request.put<any, any>(API.UPDATETRADEMARK, data);
  } else {
    return request.post<any, any>(API.ADDTRADEMARK, data);
  }
};


// 删除品牌
export const reqDeleteTrademark = (id: any) => request.delete(API.DELETETRADEMARK + id)